
package com.scalar.chiptrack.proxy;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.RandomAccessFile;
import java.io.IOException;

/**
* AppendFileOutputStream allows Logger to append to an existing file
*
* Original code copied directly from :-
*
* JAVA Network Programming
* Merlin & Conrad Huges/Michael Shoffner/Maria Winslow
* ISBN 1-884777-23-1
* Chapter 5
* Page 68
*
*/

class AppendFileOutputStream extends FileOutputStream {
    protected FileInputStream file ;

    AppendFileOutputStream(String FileName) throws IOException {
        super((new RandomAccessFile(FileName, "rw")).getFD()) ;
        
        file = new FileInputStream(getFD()) ;
        int n = file.available() ;
        
        do {
            n -= file.skip(n) ;
        } while(n > 0) ;
    }
}